<template>
  <div class="subject">
    <div v-for="(item, index) in num" :key="index">
      <span>{{ item.one }}</span>
      <span>+</span>
      <span>{{ item.two }}</span>
      <span>=</span>
      <input type="number" v-model.number="answers[index]" />
      <button @click="compute(index)">提交</button>
    </div>
  </div>
</template>
  
  <script>
export default {
  name: "SubjectItem",
  data() {
    return {
      answers: [],
    };
  },
  props: {
    num: {
      num: Array,
    },
  },
  methods: {
    compute(index) {
      this.$emit("compute", this.answers[index], index);
    },
  },
};
</script>
  
  <style scoped>
.subject {
  margin: 5px;
  padding: 5px;
  font-size: 20px;
}
.subject span {
  display: inline-block;
  text-align: center;
  width: 20px;
}
.subject input {
  width: 50px;
  height: 20px;
}
</style>